package model.location;

import model.Coordinate;
import model.Dimension;

public class WorldArea extends Area 
{
	public WorldArea(Coordinate coordinate, Dimension dimension, boolean fromCenter)
	{
		super(coordinate, dimension, fromCenter);
		
		if(fromCenter)
		{
			coordinate.setX(coordinate.getX() - (dimension.getWidth() * 0.5f));
			coordinate.setY(coordinate.getY() + (dimension.getHeight() * 0.5f));
		}
		
		_coordinate = (WorldCoordinate) coordinate;
		_dimension = dimension;
		
		setPoints();
	}

	public WorldArea(Coordinate coordinate, Dimension dimension) 
	{
		super(coordinate, dimension);
	}

	public void setPoints()
	{
		_points = new float[8];
		
		//UpperLeft
		_points[0] = _coordinate.getX();
		_points[1] = _coordinate.getY();
		
		//UpperRight
		_points[2] = _points[0] + _dimension.getWidth();
		_points[3] = _points[1];
		
		//LowerLeft
		_points[4] = _points[0];
		_points[5] = _points[1] - _dimension.getHeight();
				
		//LowerRight
		_points[6] = _points[2];
		_points[7] = _points[5];		
	}

	@Override
	public Coordinate getCenterCoord() 
	{
		return new WorldCoordinate(_coordinate.getX() + (_dimension.getWidth() * 0.5f), _coordinate.getY() - (_dimension.getHeight() * 0.5f), ((WorldCoordinate) _coordinate).getZ());
	}
}
